<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/plugins/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="/static/admin/tplay/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="/static/admin/tplay/css/admin.css"  media="all">
</head>

<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li {if condition="$info.group eq 'top'" /}class="layui-this"{/if}><a href="{:url('/index/admin.Nav/index/group/top')}">顶部导航</a></li>
        <li {if condition="$info.group eq 'main'" /}class="layui-this"{/if}><a href="{:url('/index/admin.Nav/index/group/main')}">主导航</a></li>
        <li {if condition="$info.group eq 'bottom'" /}class="layui-this"{/if}><a href="{:url('/index/admin.Nav/index/group/bottom')}">底部导航</a></li>
      </ul>
    </div>
    <div class="layui-form-item" style="float: left;">
      <button type="button" class="layui-btn">新增</button>
    </div>
    <table class="layui-table" lay-size="sm">
      <colgroup>
        <col width="50">
        <col width="120">
        <col width="100">
        <col width="100">
        <col width="150">
      </colgroup>
      <thead>
        <tr>
          <th>封面</th>
          <th>标题</th>
          <th>排序</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <form class="layui-form" id="admin"> 
      <tbody>
        {foreach name="info['nav']" item="vo"}
        <tr>
          <td>
            {notempty name="$vo.image.url"}
            <a href="{$vo.image.url}" class="tooltip"><img src="{$vo.image.url}" width="30" height="30"></a>
            {/notempty}
          </td>
          <td>{$vo.title}</td>
          <td>{$vo.sort}</td>
          <td>
            {if condition="$vo.status eq 1" /}
            <span class="layui-badge layui-bg-orange">开启</span>
            {else /}
            <span class="layui-badge layui-bg-gray">禁用</span>
            {/if}
          </td>
          <td class="operation-menu">
            <div class="layui-btn-group">
              <a href="{:url('sliderAdd',['id'=>$vo.id])}" class="layui-btn layui-btn-xs a_menu layui-btn-primary" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
              <a class="layui-btn layui-btn-xs status layui-btn-primary" data-id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="fa {if condition="$vo.status eq 1"}fa-toggle-on{else/}fa-toggle-off{/if}"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
            </div>
          </td>
        </tr>
        {/foreach}
      </tbody>
      </form>
    </table>
  
   {include file="foot"}
    <script type="text/javascript">
    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('delete')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })
    </script>
    <script type="text/javascript">
      layui.use('layer', function(){
        var layer = layui.layer;
        $('.status').click(function(){
          var id = $(this).attr('data-id');
          layer.msg('图片状态',{
            time:20000
            ,btn: ['开启', '禁用', '再想想']
            ,yes: function(index, layero){
              $.ajax({
                url:"{:url('sliderState')}"
                ,type:'post'
                ,data:{id:id,status:'1'}
                ,success:function(res){
                  layer.msg(res.msg);
                  if(res.code == 1){
                    setTimeout(function(){
                      location.href = res.url;
                    },1500)
                  }
                }
              })
            }
            ,btn2: function(index, layero){
              $.ajax({
                url:"{:url('sliderState')}"
                ,type:'post'
                ,data:{id:id,status:'-1'}
                ,success:function(res){
                  layer.msg(res.msg);
                  if(res.code == 1){
                    setTimeout(function(){
                      location.href = res.url;
                    },1500)
                  }
                }
              })
            }
          })
        })
      });              
    </script>
  </div>
</body>
</html>
